import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, OneToMany } from 'typeorm';
import { Project } from '../project/project.entity';

@Entity()
export class User {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ unique: true })
  username: string;

  @Column()
  password: string;

  @Column()
  level: number; // 1: top, 2: high, 3: mid, 4: low

  @ManyToOne(() => User, (user) => user.children, { nullable: true })
  parent: User;

  @OneToMany(() => User, (user) => user.parent)
  children: User[];

  @OneToMany(() => Project, (project) => project.owner)
  projects: Project[];
}